<template>
	<view class="Coverplayback-page">
		<swiper :indicator-dots="true" :style="{ height: screenHeight + 'px' }" :interval="3000" :duration="1000">
			<swiper-item v-for="(item, index) in posterList" :key="index">
				<view class="swiper-item">
					<image :src="item" :style="{ height: screenHeight + 'px' }" mode=""></image>
				</view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
import api from '@/common/lib/request.js';
export default {
	data() {
		return {
			time: 5,
			screenHeight: 500,
			skipText: '跳过',
			posterList: [
				 '../../static/test/1.gif',
				 '../../static/test/2.gif',
			]
		};
	},
	watch: {
		// time(newVal, oldVal) {
		// 	if (newVal == 0) {
		// 		this.skipForPosterPage();
		// 	}
		// }
	},
	onLoad() {		
		const infos = uni.getSystemInfoSync();
		console.log(infos,"lll")
		this.screenHeight = infos.windowHeight;
		this.getCoverplaybackPics()	
	},
	methods: {
		getCoverplaybackPics(){
			let _this = this;
			api.request({
					url: '/start-advertisement',
					data: {}
				})
				.then(response => {
					if(response.length > 0){
						_this.posterList = response;
					}					
				})
				.catch(err => {
					console.log(err);
				});
		},
		skipForPosterPage() {
			uni.setStorage({
				key: 'launchFlag',
				data: false
			});
			uni.switchTab({
				url: '/pages/index/index'
			});
		}
	}
};
</script>

<style scoped>
.Coverplayback-page {
	width: 100%;
	height: 100%;
}
.swiper-item {
	position: relative;
}
.swiper-item .skip-flag {
	position: absolute;
	bottom: 30upx;
	right: 30upx;
	border-radius: 10upx;
	border: 1px solid #4585af;
	color: #4585af;
	padding: 8upx 16upx;
}
</style>
